package com.zzptc.myk.myapplication.Adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;

import com.zzptc.myk.myapplication.Bean.Shoes;
import com.zzptc.myk.myapplication.R;

import java.util.List;

public class ShoesAdapter extends ArrayAdapter<Shoes> {
    int resourceid;
    public ShoesAdapter(@NonNull Context context, int resource, @NonNull List<Shoes> objects) {
        super(context, resource, objects);
        this.resourceid=resource;
    }
    @Override
    public View getView(int position, View convertView, ViewGroup parent){
        View view=convertView;
        if (view==null){
            view= LayoutInflater.from(getContext()).inflate(resourceid,null);
        }
       ImageView shoesimg=view.findViewById(R.id.shoesimg);
        TextView shoesname=view.findViewById(R.id.shoesname);
        TextView shoesPrice=view.findViewById(R.id.shoesPrice);

        Shoes b=getItem(position);
        shoesimg.setImageResource(b.getShoesimg());
        shoesname.setText(b.getShoesname());
        shoesPrice.setText("价格："+b.getShoesPrice());
        return view;
    }
}
